<template>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      v-model="form"
      :data="data"
      :page.sync="page"
      :search.sync="query"
      :permission="permissionList"
      :before-open="beforeOpen"
      ref="crud"
      @row-update="rowUpdate"
      @row-save="rowSave"
      @row-del="rowDel"
      @selection-change="selectionChange"
      @search-change="searchChange"
      @search-reset="searchReset"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
      :row-class-name="tableRowClassName"
    >
      <template slot="menuLeft">
        <!-- <el-button type="success" size="small" icon="el-icon-download" @click="handleExport">导出</el-button> -->
      </template>
      <template slot-scope="{ row }" slot="menu">
        <el-button type="text" size="small" icon="el-icon-edit" v-if="permission.shipmentBadness_handle" @click="handleEdit(row, 'edit')">不良处理</el-button>
      </template>
      <template slot="menuRight">
        <user-table-config :option="option" @confirm="(val) => handleSetUserConfig(val, pageCode)"></user-table-config>
      </template>
    </avue-crud>
    <!-- 不良处理 -->
    <el-dialog
      :fullscreen="true"
      append-to-body
      :close-on-click-modal="false"
      title="出货检验不良处理"
      :visible.sync="handleDialog"
      :before-close="handleClose"
      :close-on-press-escape="false"
    >
      <avue-form ref="basicInfoForm" v-if="handleDialog" v-model="basicInfoForm" :option="basicInfoOption"></avue-form>
      <div class="title-result">
        <div class="title">
          <i class="el-icon-vertical-bar avue-group__icon"></i>
          <h4>不良处理</h4>
        </div>
      </div>
      <avue-crud ref="bnormalRecordCrud" :option="abnormalRecordOption" :data="abnormalRecordData" @selection-change="selectionProductChange">
        <template slot="menuLeft">
          <el-tooltip class="item" effect="dark" content="处理类型" placement="top">
            <avue-radio v-model="formtype" :dic="dic"></avue-radio>
          </el-tooltip>
        </template>
        <template slot="menuRight">
          <el-button type="primary" size="small" @click="handleAddProduct">查看检验报告</el-button>
        </template>
      </avue-crud>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="handleDialog = false"><i class="el-icon-circle-close"></i><span>取 消</span></el-button>
        <el-button size="small" type="primary" @click="handleSubmit()"><i class="el-icon-circle-plus-outline"></i><span>提 交</span></el-button>
      </span>
    </el-dialog>
    <!--检验报告-->
    <el-dialog
      v-if="apaasInspectionReportDialog"
      fullscreen
      append-to-body
      :modal-append-to-body="true"
      :close-on-click-modal="false"
      title="检验报告"
      :visible.sync="apaasInspectionReportDialog"
    >
      <view-apaas-inspection-report :operateBtn="false" v-if="apaasInspectionReportDialog" ref="apaasReport"></view-apaas-inspection-report>
    </el-dialog>
    <!--公用模态弹框-->
    <common-modal-template ref="commonModalTemplate" :option="tableOption" @getSelectedRows="getSelectedRows"> </common-modal-template>
  </basic-container>
</template>
<script>
import { mapGetters } from 'vuex';
import userTableConfig from '@/components/user-table-config/index.vue';
import userConfig from '@/mixins/userConfig';
import { getLineList } from '@/api/quality/firstArticleInspection';
import commonModalTemplate from '@/components/common-modal-template/common-modal-template';
import { getList, getDetail, getListuserpage, getListPage, submitBad } from '@/api/quality/firstPiece-badness';
import viewApaasInspectionReport from '@/views/designer/preview';
/* 出货不良处理 */

export default {
  name: 'firstPiece-badness',
  components: {
    userTableConfig,
    commonModalTemplate,
    viewApaasInspectionReport
  },
  mixins: [userConfig()],
  data() {
    return {
      dic: [
        {
          label: '让步通过',
          value: 'DEVIATION'
        },
        {
          label: '二次检',
          value: 'REINSPECT'
        },
        {
          label: '返工',
          value: 'REWORK'
        }
      ],
      apaasInspectionReportDialog: false,
      form: {},
      query: {},
      tableOption: {},
      modalName: '',
      loading: false,

      page: {
        pageSize: 20,
        currentPage: 1,
        total: 0
      },
      data: [],
      option: {
        height: 'calc(100vh - 408px)',
        calcHeight: 30,
        selectionList: [],
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        indexLabel: '序号',
        columnBtn: false,
        selection: true,
        menu: true,
        menuWidth: 100,
        column: [
          {
            label: '检验单号',
            prop: 'documentNo',
            searchValue: '',
            searchOrder: 7,
            type: 'search',
            search: true,
            appendClick: () => {
              this.openDocumentNoModel();
            }
          },
          {
            label: '发货单号',
            prop: 'sourceNo',
            type: 'search',
            searchOrder: 5,
            search: true,
            appendClick: () => {
              this.openOrderNoCommon();
            }
          },
          {
            label: '客户名称',
            prop: 'partnerName',
            search: true,
            type: 'search',
            searchOrder: 3,
            appendClick: () => {
              this.openPartnerModal();
            }
          },
          {
            label: '物料编码',
            prop: 'partNo',
            type: 'search',
            search: true,
            searchOrder: 1,
            appendClick: () => {
              this.openPartModal();
            }
          },
          {
            label: '物料名称',
            prop: 'partName'
          },
          {
            label: '产品型号',
            prop: 'partModel',
            search: true,
            searchOrder: 2
          },
          {
            label: '检验状态',
            prop: 'status',
            type: 'select',
            dicData: [
              { label: '待检验', value: 1 },
              { label: '已检验', value: 2 },
              { label: '检验完成', value: 3 },
              { label: '草稿', value: 4 },
              { label: '超期关闭', value: 5 },
              { label: '已撤销', value: 6 }
            ]
          },
          {
            label: '检验结果',
            prop: 'examineResult'
          },
          {
            label: '需求数量',
            prop: 'sheetDetailQuantity'
          },
          {
            label: '报检数量',
            prop: 'sendExamineQuantity'
          },
          {
            label: '检验数量',
            prop: 'examineQuantity'
          },
          {
            label: '合格数量',
            prop: 'passQuantity'
          },
          {
            label: '不合格数量',
            prop: 'ngQuantity'
          },
          {
            label: '生产产线',
            prop: 'lineId',
            search: true,
            searchOrder: 6,
            type: 'select',
            dicData: [],
            hide: true
          },
          {
            label: '生产产线',
            prop: 'lineName'
          },
          {
            label: '是否加急',
            prop: 'isUrgent',
            search: true,
            searchOrder: 4,
            type: 'select',
            dicData: [
              { label: '是', value: true },
              { label: '否', value: false }
            ]
          },
          {
            label: '创建时间',
            prop: 'createTime'
          },
          {
            label: '检验时间',
            prop: 'examineDate'
          },
          {
            label: '检验人员',
            prop: 'sendExamineByName'
          }
          // {
          //   label: '检验日期',
          //   prop: 'examineDate',
          //   search: true,
          //   hide: true,
          //   searchOrder: 20,
          //   searchSpan: 6,
          //   width: 150,
          //   type: 'datetime',
          //   searchType: 'datetimerange',
          //   order: 18,
          //   format: 'yyyy-MM-dd HH:mm:ss',
          //   valueFormat: 'yyyy-MM-dd HH:mm:ss',
          //   startPlaceholder: '开始日期',
          //   endPlaceholder: '结束日期'
          // }
        ]
      },
      handleDialog: false,
      basicInfoForm: {},
      basicInfoOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 150,
        group: [
          {
            label: '基本信息',
            prop: 'basicInfo',
            arrow: false,
            icon: 'el-icon-vertical-bar',
            column: [
              {
                label: '检验单号',
                prop: 'documentNo',
                span: 8,
                disabled: true
              },
              {
                label: '报检时间',
                prop: 'sendExamineDate',
                span: 8,
                disabled: true
              },
              {
                label: '是否加急',
                prop: 'isUrgent',
                span: 8,
                disabled: true,
                type: 'select',
                dicData: [
                  {
                    label: '是',
                    value: true
                  },
                  {
                    label: '否',
                    value: false
                  }
                ]
              },
              {
                label: '物料编码',
                prop: 'partNo',
                span: 8,
                disabled: true
              },
              {
                label: '物料名称',
                prop: 'partName',
                span: 8,
                disabled: true
              },
              {
                label: '产品型号',
                prop: 'partModel',
                span: 8,
                disabled: true
              },
              {
                label: '发货单号',
                prop: 'sourceNo',
                span: 8,
                disabled: true
              },
              {
                label: '客户名称',
                prop: 'partnerName',
                span: 8,
                disabled: true
              },
              {
                label: '检验人员',
                prop: 'examineByName',
                span: 8,
                disabled: true
              }
            ]
          },
          {
            label: '检验结果',
            prop: 'revoke',
            arrow: false,
            icon: 'el-icon-vertical-bar',
            column: [
              {
                label: '检验结果',
                prop: 'examineResult',
                span: 8,
                disabled: true
              },
              {
                label: '合格数量',
                prop: 'passQuantity',
                span: 8,
                disabled: true
              },
              {
                label: '不合格数量',
                prop: 'ngQuantity',
                span: 8,
                disabled: true
              }
            ]
          }
        ]
      },
      abnormalRecordData: [],
      abnormalRecordOption: {
        height: '300',
        calcHeight: 30,
        tip: false,
        border: true,
        index: true,
        indexLabel: '序号',
        selection: true,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        viewBtn: false,
        menu: false,
        refreshBtn: false,
        columnBtn: false,
        column: [
          {
            label: '不良序列号',
            prop: 'objectNo'
          },
          {
            label: '不良现象',
            prop: 'ngFailureName'
          },
          {
            label: '不良原因（大类）',
            prop: 'ngMainCauseName'
          },
          {
            label: '不良原因（小类）',
            prop: 'ngSubCauseName'
          },
          {
            label: '不良说明',
            prop: 'faultDescription'
          },
          // {
          //   label: '不良工序',
          //   prop: 'routeName',
          //   type: 'search',
          //   cell: true,
          //   disabled: true,
          //   appendClick: () => {
          //     this.openUserCommonModal();
          //   }
          // },
          // {
          //   label: '不良工序',
          //   prop: 'routeName',
          //   cell: true,
          //   type: 'select',
          //   dicData: []
          // },
          {
            label: '改善措施',
            prop: 'improvementMeasure',
            cell: true,
            width: 300
          },
          {
            label: '负责人',
            prop: 'principalName',
            cell: true,
            type: 'select',
            dicData: []
          },
          {
            label: '备注',
            prop: 'remark'
          }
        ]
      },
      lineList: [],
      documentNo: '',
      pictureList: [],
      abnormalRecordIndex: 0,
      mainTypeList: [],
      subTypeList: [],
      openHandleDialogType: 'edit',

      exportData: [],
      workSectionList: []
    };
  },
  watch: {},
  mounted() {
    this.$nextTick(() => {
      this.$structuralSplit();
    });
    const optionLineId = this.findObject(this.option.column, 'lineId');
    getLineList().then(
      (res) => {
        optionLineId.dicData = this._map(res.data.data, (item) => {
          return {
            label: item.name,
            value: item.id
          };
        });
      },
      (error) => {
        optionLineId.dicData = [];
      }
    );
  },
  computed: {
    ...mapGetters(['permission']),
    permissionList() {
      return {
        delBtn: this.vaildData(this.permission.shipmentBadness_handle, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(',');
    }
  },
  methods: {
    async downLoad(file) {
      const data = {
        originalName: file.originalName,
        attachType: 'QMS'
      };
      try {
        const res = await exprot({ data });
        const blob = new Blob([res.data]);
        const fileName = file.originalName;
        const link = document.createElement('a');
        link.download = fileName;
        link.style.display = 'none';
        link.href = URL.createObjectURL(blob);
        document.body.append(link);
        link.click();
        URL.revokeObjectURL(link.href);
        document.body.removeChild(link);
      } catch (e) {
        const failMsg = await this.blobToJson(e.data);
        this.$message.error(failMsg.msg);
      }
    },
    async blobToJson(blob) {
      return new Promise((resolve, reject) => {
        blob.arrayBuffer().then(
          async (arrayBuffer) => {
            resolve(JSON.parse(Buffer.from(arrayBuffer).toString('utf-8')));
          },
          (error) => {
            reject(error);
          }
        );
      });
    },
    rowSave(row, done, loading) {},
    rowUpdate(row, index, done, loading) {},
    rowDel(row) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          // ajax
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
        });
    },
    handleAdd() {
      this.addDialog = true;
      this.addForm.documentSubTyp = 'WORKORDER';
    },
    handleAddProduct() {
      if (!this.basicInfoForm.examineContent) {
        this.$message({
          type: 'warning',
          message: '检验报告信息不存在!'
        });
        return;
      }
      let examineContent = JSON.parse(this.basicInfoForm.examineContent || '{}');
      this.apaasInspectionReportDialog = true;
      this.$nextTick(() => {
        this.$refs.apaasReport.setDataJson(examineContent);
      });
    },
    handleEdit(row, type) {
      this.getFailureList();
      this.handleDialog = true;
      this.openHandleDialogType = type;
      this.$nextTick(() => {
        this.$refs.basicInfoForm.allDisabled = false;
      });

      this.inspectionPictureList = [];
      this.formtype = 'DEVIATION';
      getDetail(row.id).then((res) => {
        this.basicInfoForm = this._get(res, 'data.data', {});
        this.basicInfoForm.submitId = row.id;
        this.basicInfoForm.examineBy = this.basicInfoForm.examineBy ? this.basicInfoForm.examineBy : JSON.parse(localStorage.getItem('saber-userInfo')).content.user_id;
        this.basicInfoForm.examineByName = this.basicInfoForm.examineByName
          ? this.basicInfoForm.examineByName
          : JSON.parse(localStorage.getItem('saber-userInfo')).content.user_name;
        this.abnormalRecordData = this._get(res, 'data.data.qmsInspectionExceptionVoList', []);
        if (this.abnormalRecordData.length > 0) {
          this._forEach(this.abnormalRecordData, (item) => {
            item.$cellEdit = true;
          });
        }
        console.log(this.abnormalRecordData);
      });
    },
    getFailureList() {
      const principalName = this.findObject(this.abnormalRecordOption.column, 'principalName');
      // const routeName = this.findObject(this.abnormalRecordOption.column, 'routeName');
      getListuserpage(1, 99).then(
        (res) => {
          principalName.dicData = this._map(this._get(res, 'data.data.records', []), (item) => {
            return {
              label: item.name,
              value: JSON.stringify({ principalId: item.id, principalName: item.name })
            };
          });
        },
        (error) => {
          principalName.dicData = [];
        }
      );
      // getListPage(1, 999).then(
      //   (res) => {
      //     routeName.dicData = this._map(this._get(res, 'data.data.records', []), (item) => {
      //       return {
      //         label: item.name,
      //         value: JSON.stringify({ routeId: item.id, routeName: item.name })
      //       };
      //     });
      //   },
      //   (error) => {
      //     routeName.dicData = [];
      //   }
      // );
    },
    handleClose(done) {
      done();
    },

    beforeOpen(done, type) {},
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    searchChange(params, done) {
      if (params.examineDate && params.examineDate.length > 0) {
        params.examineStartTime = params.examineDate[0];
        params.examineEndTime = params.examineDate[1];
      }
      delete params.examineDate;
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    getSelectedRows(rowData) {
      this.query.partNo = rowData.partNo || '';
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query, { documentType: 'OQC' })).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });
    },
    getSubTypeList(id) {
      const column = this.findObject(this.abnormalOption.column, 'subType');
      getSubTypeList(id).then(
        (res) => {
          this.subTypeList = this._get(res, 'data.data.subList', []);
          column.dicData = this._get(res, 'data.data.subList', []);
          column.dicData = this._map(column.dicData, (item) => {
            return {
              label: item.name,
              value: item.id
            };
          });
        },
        (error) => {
          column.dicData = [];
        }
      );
    },

    openFailureCommonModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'failureModal';
      this.tableOption = {
        modalTitle: '不良现象（双击进行选择）',
        url: '/api/mes-product/mro-dict/page?dictType=BAD_PHENOMENON',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '不良代码',
            prop: 'code',
            search: true
          },
          {
            label: '不良现象描述',
            prop: 'name'
          }
        ]
      };
    },
    /**
     * 选择模态框行数据
     */
    getSelectedRows(rowData) {
      switch (this.modalName) {
        case 'failureModal':
          this.abnormalForm.failureId = rowData.id;
          this.abnormalForm.failureCode = rowData.code;
          this.abnormalForm.failureName = rowData.name;
          break;

        case 'userModal':
          this.basicInfoForm.examineBy = rowData.id;
          this.basicInfoForm.examineByName = rowData.realName;
          break;
        case 'partnerModal':
          this.$set(this.query, 'partnerName', rowData.name);
          break;
        case 'documentNoModel':
          this.$set(this.query, 'documentNo', rowData.documentNo);
          break;
        case 'partNoModal':
          this.$set(this.query, 'partNo', rowData.partNo);
          break;
        case 'workOrderNoModal':
          this.$set(this.query, 'sourceNo', rowData.sheetNo);
          break;
        default:
          break;
      }
    },
    getWorkOrderDetail(workOrderNo) {
      getWorkOrderDetail(workOrderNo, 'FAI').then((res) => {
        this.addForm.workshopId = this._get(res, 'data.data.workOrderVO.workshopId', '');
        this.addForm.workshopName = this._get(res, 'data.data.workOrderVO.workshopName', '');
        this.addForm.lotNo = this._get(res, 'data.data.workOrderVO.lotNo', '');
        this.documentNo = this._get(res, 'data.data.documentNo', '');
      });
    },

    /**
     * 上传前方法
     */
    pictureUploadBefore(file) {
      console.log(file);
      if (file.name.split('.')[1] != 'png' && file.name.split('.')[1] != 'jpeg' && file.name.split('.')[1] != 'jpg') {
        this.$message({
          type: 'warning',
          message: '只能上传png/jpeg/jpg文件！'
        });
        return false;
      }
    },
    pictureUploadSuccess(res) {
      if (this.abnormalForm['attachments'] === null) {
        this.abnormalForm['attachments'] = [];
      }
      this.abnormalForm['attachments'].push({
        attachmentId: res.data.attachId,
        link: res.data.link,
        attachmentName: res.data.originalName,
        attachmentType: 'INSPECTION'
      });
      console.log(this.abnormalForm['attachments']);
    },

    addAbnormalDialogClose(done) {
      this.$refs.abnormalForm.resetFields();
      this.abnormalForm = {};
      done();
    },

    handleSubmit() {
      let arr = [];
      this.abnormalRecordData.forEach((element, index) => {
        arr.push({
          id: element.id,
          improvementMeasure: element.improvementMeasure,
          // ...JSON.parse(element.routeName),
          ...JSON.parse(element.principalName)
        });
      });

      for (let i = 0; i < arr.length; i++) {
        if (!arr[i].improvementMeasure) {
          this.$message.error(`改善措施不能为空！`);
          done();
          return;
        }
      }

      let params = {
        id: this.basicInfoForm.submitId,
        disposeType: this.formtype,
        qmsInspectionExceptionVoList: arr
      };
      submitBad(params).then(
        (res) => {
          this.handleDialog = false;
          this.$message.success(res.data.msg);
          this.onLoad(this.page);
          done();
        },
        (error) => {
          done();
        }
      );
    },
    abnormalRecordRowUpdate(row, type) {
      console.log(row);
      if (type === 'edit') {
        this.abnormalRecordIndex = row.$index;
        this.$nextTick(() => {
          this.$refs.abnormalForm.allDisabled = false;
        });
      } else {
        this.$nextTick(() => {
          this.$refs.abnormalForm.allDisabled = true;
        });
      }
      this.abnormalForm = row;
      this.abnormalForm.subType = [];
      this._forEach(row.qmsInspectionExceptionDetailList, (item) => {
        if (item.dictType === 'FAILURE') {
          this.abnormalForm.failureId = item.dictId;
          this.abnormalForm.failureCode = item.dictCode;
          this.abnormalForm.failureName = item.dictName;
        } else {
          if (item.subType === 'MAIN') {
            this.abnormalForm.mainType = item.dictId;
          } else {
            this.abnormalForm.subType.push(item.dictId);
          }
        }
      });
      this.abnormalForm.attachments = this._map(row.qmsInspectionAttachmentList, (item) => {
        this.pictureList.push({
          name: item.attachmentName,
          url: item.link
        });
        return {
          attachmentId: item.attachmentId,
          link: item.link,
          attachmentName: item.attachmentName,
          attachmentType: 'INSPECTION'
        };
      });
    },
    abnormalRecordDel(index) {
      this.abnormalRecordData.splice(index, 1);
    },

    openUserCommonModal() {
      this.modalName = 'userModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择检验人员信息（双击进行选择）',
        url: '/api/blade-system/user/page',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '用户姓名',
            prop: 'realName',
            search: true,
            searchLabelWidth: 150,
            searchSpan: 8
          },
          {
            label: '所属部门',
            prop: 'deptName',
            searchLabelWidth: 150,
            searchSpan: 8
          },
          {
            label: '职务',
            prop: 'postName'
          },
          {
            label: '用户平台',
            prop: 'userTypeName'
          }
        ]
      };
    },
    openOrderNoCommon() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'workOrderNoModal';
      this.tableOption = {
        modalTitle: '选择发货单号（双击进行选择）',
        url: '/api/mes-warehouse/sheetheader/page?current=1&size=10&sheetType=DO',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '发货单号',
            prop: 'sheetNo',
            search: true
          },
          {
            label: '客户',
            prop: 'partnerName',
            search: true
          },
          {
            label: '客户编码',
            prop: 'partnerCode',
            search: true
          }
        ]
      };
    },
    openDocumentNoModel() {
      this.modalName = 'documentNoModel';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择检验单号（双击进行选择）',
        url: '/api/mes-product/qms-inspection-document/page?statusStr=1,4&document_type=FQC',
        isPage: true,
        index: true,
        indexLabel: '序号',
        selection: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '检验单号',
            prop: 'documentNo',
            search: true
          },
          {
            label: '生产工单',
            prop: 'sourceNo'
          },
          {
            label: '客户名称',
            prop: 'partnerName'
          },
          {
            label: '物料编码',
            prop: 'partNo'
          },
          {
            label: '物料名称',
            prop: 'partName'
          },
          {
            label: '产品型号',
            prop: 'partModel'
          }
        ]
      };
    },
    openPartnerModal() {
      this.modalName = 'partnerModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择客户信息（双击进行选择）',
        url: '/api/mes-admin/customer/page',
        isPage: true,
        index: true,
        indexLabel: '序号',
        selection: true,
        rowSelectionType: 'single',
        titleInfo: 'partnerInfo',
        columnDefs: [
          {
            label: '编码',
            prop: 'code',
            search: true
          },
          {
            label: '名称',
            prop: 'name',
            search: true
          }
        ]
      };
    },
    // 物料编码
    openPartModal() {
      this.modalName = 'partNoModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '物料数据（双击进行选择）',
        url: '/api/mes-admin/part-master/page?semifinished=true',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '物料编码',
            prop: 'partNo',
            search: true
          },
          {
            label: '物料名称',
            prop: 'name',
            search: true
          },
          {
            label: '产品型号',
            prop: 'partModel'
          }
        ]
      };
    },
    tableRowClassName({ row }) {
      if (row.isUrgent) {
        return 'importRow';
      }
      return '';
    }
  }
};
</script>

<style lang="scss" scoped>
.titleIcon {
  display: flex;
  align-items: center;
}
.title-result {
  display: flex;
  justify-content: space-between;
  .title {
    display: flex;
    align-items: center;
  }
  .reslut-btn-group {
    margin-right: 8px;
  }
}

.download-box {
  .dowload-item {
    margin: 4px 8px;
    color: #007dff;
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
    user-select: none;
    &:hover {
      cursor: pointer;
    }
  }
}
::v-deep .importRow {
  background-color: #ffff00 !important;
}

.dialog-title {
  position: relative;
  .title {
    display: inline-block;
  }
  .fullscreen-icon {
    position: absolute;
    right: 20px;
    cursor: pointer;
    display: inline-block;
    font-size: 14px;
    color: #909399;
    &:hover {
      color: #0a84ff;
    }
  }
}

.fullscreen {
  ::v-deep .el-dialog {
    width: 100%;
    margin: 0 !important;
    margin-top: 0vh !important;
  }
}
.no_fullScreen {
  ::v-deep.el-dialog {
    width: 50%;
    margin-top: 5vh !important;
  }
}
</style>
